home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / sun / volume2 / contool3.0 / part02 < prev    next >
Encoding:
Internet Message Format  |  1990-09-25  |  42.8 KB

  1. Path: uunet!know!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!apple!sun-barr!rutgers!aramis.rutgers.edu!mcgrew
  2. From: mcgrew@aramis.rutgers.edu (Charles Mcgrew)
  3. Newsgroups: comp.sources.sun
  4. Subject: v02i021:  Contool 3.0, Part02/06
  5. Message-ID: <Sep.25.16.10.43.1990.25376@aramis.rutgers.edu>
  6. Date: 25 Sep 90 20:10:45 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 1502
  9. Approved: mcgrew@aramis.rutgers.edu
  10.  
  11. Submitted-by: chuck@trantor.harris-atd.com (Chuck Musciano)
  12. Posting-number: Volume 2, Issue 21
  13. Archive-name: contool3.0/part02
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 2 (of 6)."
  22. # Contents:  contool_ui.h lex.c logging.c misc.c parse.y regexp.c
  23. #   store.c
  24. # Wrapped by chuck@melmac on Fri Aug 17 10:00:51 1990
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'contool_ui.h' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'contool_ui.h'\"
  28. else
  29. echo shar: Extracting \"'contool_ui.h'\" \(5115 characters\)
  30. sed "s/^X//" >'contool_ui.h' <<'END_OF_FILE'
  31. X#ifndef    contool_HEADER
  32. X#define    contool_HEADER
  33. X
  34. X/*
  35. X * contool_ui.h - User interface object and function declarations.
  36. X * This file was generated by `gxv' from `contool.G'.
  37. X * DO NOT EDIT BY HAND.
  38. X */
  39. X
  40. Xextern Attr_attribute    INSTANCE;
  41. X
  42. Xextern Xv_opaque    contool_file_menu_create();
  43. Xextern Xv_opaque    contool_view_menu_create();
  44. Xextern Xv_opaque    contool_edit_menu_create();
  45. Xextern Xv_opaque    contool_filter_insert_menu_create();
  46. Xextern Xv_opaque    contool_filter_edit_menu_create();
  47. Xextern Xv_opaque    contool_filter_paste_menu_create();
  48. X
  49. Xtypedef struct {
  50. X    Xv_opaque    base;
  51. X    Xv_opaque    contool_controls;
  52. X    Xv_opaque    file;
  53. X    Xv_opaque    view;
  54. X    Xv_opaque    edit;
  55. X    Xv_opaque    display;
  56. X} contool_base_objects;
  57. X
  58. Xextern contool_base_objects    *contool_base_objects_initialize();
  59. X
  60. Xextern Xv_opaque    contool_base_base_create();
  61. Xextern Xv_opaque    contool_base_contool_controls_create();
  62. Xextern Xv_opaque    contool_base_file_create();
  63. Xextern Xv_opaque    contool_base_view_create();
  64. Xextern Xv_opaque    contool_base_edit_create();
  65. Xextern Xv_opaque    contool_base_display_create();
  66. X
  67. Xtypedef struct {
  68. X    Xv_opaque    props;
  69. X    Xv_opaque    prop_controls;
  70. X    Xv_opaque    default_action;
  71. X    Xv_opaque    default_beep_count;
  72. X    Xv_opaque    default_beep_times;
  73. X    Xv_opaque    default_command;
  74. X    Xv_opaque    log_file;
  75. X    Xv_opaque    log_style;
  76. X    Xv_opaque    print_filter;
  77. X    Xv_opaque    good_icon;
  78. X    Xv_opaque    bad_icon;
  79. X    Xv_opaque    flash_icon;
  80. X    Xv_opaque    stamp_resolution;
  81. X    Xv_opaque    message2;
  82. X    Xv_opaque    max_message;
  83. X    Xv_opaque    message3;
  84. X    Xv_opaque    delete_amount;
  85. X    Xv_opaque    message4;
  86. X    Xv_opaque    props_apply;
  87. X    Xv_opaque    props_reset;
  88. X} contool_props_objects;
  89. X
  90. Xextern contool_props_objects    *contool_props_objects_initialize();
  91. X
  92. Xextern Xv_opaque    contool_props_props_create();
  93. Xextern Xv_opaque    contool_props_prop_controls_create();
  94. Xextern Xv_opaque    contool_props_default_action_create();
  95. Xextern Xv_opaque    contool_props_default_beep_count_create();
  96. Xextern Xv_opaque    contool_props_default_beep_times_create();
  97. Xextern Xv_opaque    contool_props_default_command_create();
  98. Xextern Xv_opaque    contool_props_log_file_create();
  99. Xextern Xv_opaque    contool_props_log_style_create();
  100. Xextern Xv_opaque    contool_props_print_filter_create();
  101. Xextern Xv_opaque    contool_props_good_icon_create();
  102. Xextern Xv_opaque    contool_props_bad_icon_create();
  103. Xextern Xv_opaque    contool_props_flash_icon_create();
  104. Xextern Xv_opaque    contool_props_stamp_resolution_create();
  105. Xextern Xv_opaque    contool_props_message2_create();
  106. Xextern Xv_opaque    contool_props_max_message_create();
  107. Xextern Xv_opaque    contool_props_message3_create();
  108. Xextern Xv_opaque    contool_props_delete_amount_create();
  109. Xextern Xv_opaque    contool_props_message4_create();
  110. Xextern Xv_opaque    contool_props_props_apply_create();
  111. Xextern Xv_opaque    contool_props_props_reset_create();
  112. X
  113. Xtypedef struct {
  114. X    Xv_opaque    filters;
  115. X    Xv_opaque    filter_controls;
  116. X    Xv_opaque    filter_list;
  117. X    Xv_opaque    filter_insert;
  118. X    Xv_opaque    filter_edit;
  119. X    Xv_opaque    filter_update;
  120. X    Xv_opaque    filter_type;
  121. X    Xv_opaque    start;
  122. X    Xv_opaque    stop;
  123. X    Xv_opaque    comment;
  124. X    Xv_opaque    ignore;
  125. X    Xv_opaque    action;
  126. X    Xv_opaque    filter_beep_count;
  127. X    Xv_opaque    filter_beep_times;
  128. X    Xv_opaque    filter_command;
  129. X    Xv_opaque    filters_apply;
  130. X    Xv_opaque    filters_reset;
  131. X} contool_filters_objects;
  132. X
  133. Xextern contool_filters_objects    *contool_filters_objects_initialize();
  134. X
  135. Xextern Xv_opaque    contool_filters_filters_create();
  136. Xextern Xv_opaque    contool_filters_filter_controls_create();
  137. Xextern Xv_opaque    contool_filters_filter_list_create();
  138. Xextern Xv_opaque    contool_filters_filter_insert_create();
  139. Xextern Xv_opaque    contool_filters_filter_edit_create();
  140. Xextern Xv_opaque    contool_filters_filter_update_create();
  141. Xextern Xv_opaque    contool_filters_filter_type_create();
  142. Xextern Xv_opaque    contool_filters_start_create();
  143. Xextern Xv_opaque    contool_filters_stop_create();
  144. Xextern Xv_opaque    contool_filters_comment_create();
  145. Xextern Xv_opaque    contool_filters_ignore_create();
  146. Xextern Xv_opaque    contool_filters_action_create();
  147. Xextern Xv_opaque    contool_filters_filter_beep_count_create();
  148. Xextern Xv_opaque    contool_filters_filter_beep_times_create();
  149. Xextern Xv_opaque    contool_filters_filter_command_create();
  150. Xextern Xv_opaque    contool_filters_filters_apply_create();
  151. Xextern Xv_opaque    contool_filters_filters_reset_create();
  152. X
  153. Xtypedef struct {
  154. X    Xv_opaque    load;
  155. X    Xv_opaque    load_controls;
  156. X    Xv_opaque    load_type;
  157. X    Xv_opaque    load_file;
  158. X    Xv_opaque    accept_load;
  159. X} contool_load_objects;
  160. X
  161. Xextern contool_load_objects    *contool_load_objects_initialize();
  162. X
  163. Xextern Xv_opaque    contool_load_load_create();
  164. Xextern Xv_opaque    contool_load_load_controls_create();
  165. Xextern Xv_opaque    contool_load_load_type_create();
  166. Xextern Xv_opaque    contool_load_load_file_create();
  167. Xextern Xv_opaque    contool_load_accept_load_create();
  168. X
  169. Xtypedef struct {
  170. X    Xv_opaque    store;
  171. X    Xv_opaque    store_controls;
  172. X    Xv_opaque    store_type;
  173. X    Xv_opaque    store_file;
  174. X    Xv_opaque    accept_store;
  175. X} contool_store_objects;
  176. X
  177. Xextern contool_store_objects    *contool_store_objects_initialize();
  178. X
  179. Xextern Xv_opaque    contool_store_store_create();
  180. Xextern Xv_opaque    contool_store_store_controls_create();
  181. Xextern Xv_opaque    contool_store_store_type_create();
  182. Xextern Xv_opaque    contool_store_store_file_create();
  183. Xextern Xv_opaque    contool_store_accept_store_create();
  184. X#endif
  185. END_OF_FILE
  186. if test 5115 -ne `wc -c <'contool_ui.h'`; then
  187.     echo shar: \"'contool_ui.h'\" unpacked with wrong size!
  188. fi
  189. # end of 'contool_ui.h'
  190. fi
  191. if test -f 'lex.c' -a "${1}" != "-c" ; then 
  192.   echo shar: Will not clobber existing file \"'lex.c'\"
  193. else
  194. echo shar: Extracting \"'lex.c'\" \(6635 characters\)
  195. sed "s/^X//" >'lex.c' <<'END_OF_FILE'
  196. X/************************************************************************/
  197. X/*    Copyright 1988-1990 by Chuck Musciano and Harris Corporation    */
  198. X/*                                    */
  199. X/*    Permission to use, copy, modify, and distribute this software    */
  200. X/*    and its documentation for any purpose and without fee is    */
  201. X/*    hereby granted, provided that the above copyright notice    */
  202. X/*    appear in all copies and that both that copyright notice and    */
  203. X/*    this permission notice appear in supporting documentation, and    */
  204. X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  205. X/*    used in advertising or publicity pertaining to distribution    */
  206. X/*    of the software without specific, written prior permission.    */
  207. X/*    Chuck Musciano and Harris Corporation make no representations    */
  208. X/*    about the suitability of this software for any purpose.  It is    */
  209. X/*    provided "as is" without express or implied warranty.  This     */
  210. X/*    software may not be sold without the prior explicit permission    */
  211. X/*    of Harris Corporation.                        */
  212. X/************************************************************************/
  213. X
  214. X#define        RETURN(x)        return(last_token = (x))
  215. X
  216. X#define        FIRST_KEYWORD        BEEP
  217. X#define        LAST_KEYWORD        YES
  218. X#define        NUM_KEYWORDS        (LAST_KEYWORD - FIRST_KEYWORD + 1)
  219. X
  220. XPRIVATE    FILE    *f = NULL;
  221. XPRIVATE    int    last_token = -1;
  222. XPRIVATE    char    buf[1024];
  223. X
  224. XPRIVATE    struct    {char    *name;
  225. X         int    value;
  226. X        } token[] = {{"beep",                 BEEP},
  227. X                 {"check_icon",           CHECK_ICON},
  228. X                 {"command",              COMMAND},
  229. X                 {"comment",              COMMENT},
  230. X                 {"defaults",             DEFAULTS},
  231. X                 {"delete",               DELETE},
  232. X                 {"display",              DISPLAY},
  233. X                 {"filters",              FILTERS},
  234. X                 {"flash",                FLASH},
  235. X                 {"flash_icon",           FLASH_ICON},
  236. X                 {"good_icon",            GOOD_ICON},
  237. X                 {"ignore",               IGNORE},
  238. X                 {"log_before_filtering", LOG_BEFORE_FILTERING},
  239. X                 {"log_file",             LOG_FILE},
  240. X                 {"match",                MATCH},
  241. X                 {"no"     ,              NO},
  242. X                 {"noflash",              NOFLASH},
  243. X                 {"noopen",               NOOPEN},
  244. X                 {"nostamp",              NOSTAMP},
  245. X                 {"open",                 OPEN},
  246. X                 {"print",                PRINT},
  247. X                 {"save",                 SAVE},
  248. X                 {"stamp",                STAMP},
  249. X                 {"timestamp",            TIMESTAMP},
  250. X                 {"to",                   TO},
  251. X                 {"yes",                  YES}};
  252. X
  253. XPRIVATE    struct    {char    first;
  254. X         char    next;
  255. X         int    name;
  256. X        } punc[] = {{'{',  '\0', LBRACE},
  257. X                {'}',  '\0', RBRACE},
  258. X                {'\0', '\0', -1}};
  259. X
  260. X/************************************************************************/
  261. XEXPORT    int    lex_init(path)
  262. X
  263. Xchar    *path;
  264. X
  265. X{
  266. X    if (f)
  267. X       fclose(f);
  268. X    if (f = fopen(path, "r")) {
  269. X       curr_file = strsave(path);
  270. X       line_count = 1;
  271. X       ungetc = -1;
  272. X       parse_errors_occured = 0;
  273. X       return(TRUE);
  274. X       }
  275. X    else
  276. X       return(FALSE);
  277. X}
  278. X
  279. X/************************************************************************/
  280. XPRIVATE    char    getch()
  281. X
  282. X{    register    char    c;
  283. X    static        int    first = TRUE;
  284. X
  285. X    if (ungetc != -1)
  286. X       c = ungetc, ungetc = -1;
  287. X    else {
  288. X       c = getc(f);
  289. X       if (c == '\n')
  290. X          line_count++;
  291. X       }
  292. X    return(c);
  293. X}
  294. X
  295. X/************************************************************************/
  296. XPRIVATE    fix_escapes(buf)
  297. X
  298. Xchar    *buf;
  299. X
  300. X{    char    *q;
  301. X    int    i;
  302. X
  303. X    for (q = buf; *buf; buf++, q++)
  304. X       if (*buf == '\\')
  305. X          *q = *++buf;
  306. X       else
  307. X          *q = *buf;
  308. X    *q = '\0';
  309. X}
  310. X
  311. X/************************************************************************/
  312. XPRIVATE    int    is_keyword(s)
  313. X
  314. Xchar    *s;
  315. X
  316. X{    register    int    cmp, high, low, pos;
  317. X
  318. X    for (low = 0, high = NUM_KEYWORDS - 1; low <= high; )
  319. X       if ((cmp = strcmp(s, token[pos = (high - low) / 2 + low].name)) == 0)
  320. X          return(token[pos].value);
  321. X       else if (cmp < 0)
  322. X          high = pos - 1;
  323. X       else
  324. X          low = pos + 1;
  325. X    return(NULL);
  326. X}
  327. X
  328. X/************************************************************************/
  329. XPRIVATE    int    yylex()
  330. X
  331. X{    register    char    c, c1, *p;
  332. X    register    int    i, j, val;
  333. X    char            *index();
  334. X    double            atof();
  335. X
  336. X    c = getch();
  337. X    while (isspace(c))
  338. X       c = getch();
  339. X    if (isalpha(c)) {
  340. X       p = buf;
  341. X       *p++ = c;
  342. X       while (isalnum(c = getch()) || c == '_')
  343. X          *p++ = c;
  344. X       ungetc = c;
  345. X       *p = '\0';
  346. X       for (p = buf; *p; p++)
  347. X          if (isupper(*p))
  348. X             *p = tolower(*p);
  349. X       if (i = is_keyword(buf))
  350. X          RETURN(i);
  351. X       else {
  352. X          yyerror("unexpected keyword: %s", buf);
  353. X          fclose(f);
  354. X          f = NULL;
  355. X          RETURN(EOF);
  356. X          }
  357. X       }
  358. X    else if (c == '"' || c == '\'') {
  359. X       for (p = buf; TRUE; p++)
  360. X          if ((*p = getch()) == c)
  361. X             break;
  362. X          else if (*p == '\\')
  363. X             *++p = getch();
  364. X          else if (*p == '\n' || *p == '\r') {
  365. X             yyerror("Newline in string not allowed");
  366. X             break;
  367. X             }
  368. X       *p = '\0';
  369. X       fix_escapes(buf);
  370. X       yylval.cpval = strsave(buf);
  371. X       RETURN(STRING);
  372. X       }
  373. X    else if (isdigit(c)) {
  374. X       p = buf;
  375. X       *p++ = c;
  376. X       while (isdigit(c = getch()))
  377. X          *p++ = c;
  378. X       *p = '\0';
  379. X       ungetc = c;
  380. X       yylval.ival = atoi(buf);
  381. X       RETURN(INTEGER);
  382. X       }
  383. X    else if (c == '#') {
  384. X       while ((c = getch()) != '\n' && c != EOF)
  385. X          ;
  386. X       if (c == EOF) {
  387. X          fclose(f);
  388. X          f = NULL;
  389. X          RETURN(EOF);
  390. X          }
  391. X       else
  392. X          RETURN(yylex());
  393. X       }
  394. X    else if (c == EOF) {
  395. X       fclose(f);
  396. X       f = NULL;
  397. X       RETURN(EOF);
  398. X       }
  399. X    else {
  400. X       for (i = 0; punc[i].first; i++)
  401. X          if (c == punc[i].first) {
  402. X             for (c1 = getch(), j = 1; punc[i + j].first == c; j++)
  403. X                if (c1 == punc[i + j].next)
  404. X                   RETURN(punc[i + j].name);
  405. X             ungetc = c1;
  406. X             RETURN(punc[i].name);
  407. X             }
  408. X       yyerror("Invalid character in source file: %c (0x%02x)", c, c);
  409. X       }
  410. X    RETURN(yylex());
  411. X}
  412. X
  413. X/************************************************************************/
  414. XPRIVATE    char    *get_last_token()
  415. X
  416. X{    int    i;
  417. X    static    char    msg[512];
  418. X
  419. X    if (last_token == INTEGER || last_token == STRING)
  420. X       sprintf(msg, "\"%s\"", buf);
  421. X    else if (last_token >= LBRACE && last_token <= RBRACE) {
  422. X       for (i = 0; punc[i].first; i++)
  423. X          if (punc[i].name == last_token) {
  424. X             sprintf(msg, "\"%c\"", punc[i].first);
  425. X             if (punc[i].next)
  426. X                sprintf(msg + 2, "%c\"", punc[i].next);
  427. X             break;
  428. X             }
  429. X       if (punc[i].first == '\0')
  430. X          sprintf(msg, "!!Geez!  Some punctuation, I don't know!!");
  431. X       }
  432. X    else if (last_token >= FIRST_KEYWORD && last_token <= LAST_KEYWORD)
  433. X       sprintf(msg, "\"%s\"", token[last_token - FIRST_KEYWORD].name);
  434. X    else if (last_token == EOF)
  435. X       sprintf(msg, "End Of File");
  436. X    else
  437. X       sprintf(msg, "!!Geez!  Some keyword, I don't know!!");
  438. X    return(msg);
  439. X}
  440. END_OF_FILE
  441. if test 6635 -ne `wc -c <'lex.c'`; then
  442.     echo shar: \"'lex.c'\" unpacked with wrong size!
  443. fi
  444. # end of 'lex.c'
  445. fi
  446. if test -f 'logging.c' -a "${1}" != "-c" ; then 
  447.   echo shar: Will not clobber existing file \"'logging.c'\"
  448. else
  449. echo shar: Extracting \"'logging.c'\" \(4036 characters\)
  450. sed "s/^X//" >'logging.c' <<'END_OF_FILE'
  451. X/************************************************************************/
  452. X/*    Copyright 1988-1990 by Chuck Musciano and Harris Corporation    */
  453. X/*                                    */
  454. X/*    Permission to use, copy, modify, and distribute this software    */
  455. X/*    and its documentation for any purpose and without fee is    */
  456. X/*    hereby granted, provided that the above copyright notice    */
  457. X/*    appear in all copies and that both that copyright notice and    */
  458. X/*    this permission notice appear in supporting documentation, and    */
  459. X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  460. X/*    used in advertising or publicity pertaining to distribution    */
  461. X/*    of the software without specific, written prior permission.    */
  462. X/*    Chuck Musciano and Harris Corporation make no representations    */
  463. X/*    about the suitability of this software for any purpose.  It is    */
  464. X/*    provided "as is" without express or implied warranty.  This     */
  465. X/*    software may not be sold without the prior explicit permission    */
  466. X/*    of Harris Corporation.                        */
  467. X/************************************************************************/
  468. X
  469. X/************************************************************************/
  470. X/*                                    */
  471. X/*    logging.c    message log management                */
  472. X/*                                    */
  473. X/************************************************************************/
  474. X
  475. X#include    <stdio.h>
  476. X#include    <sys/param.h>
  477. X#include    <sys/types.h>
  478. X#include    <xview/xview.h>
  479. X#include    <xview/panel.h>
  480. X#include    <xview/xv_xrect.h>
  481. X
  482. X#include    "manifest.h"
  483. X#include    "contool.h"
  484. X#include    "contool_ui.h"
  485. X
  486. XPUBLIC    Menu_item    start_logging();
  487. XPUBLIC    Menu_item    stop_logging();
  488. X
  489. XPUBLIC    contool_base_objects    *contool_base;
  490. X
  491. XPRIVATE    int    logging = FALSE;
  492. XPRIVATE    FILE    *logfile = NULL;
  493. XPRIVATE    char    *log_path = NULL;
  494. X
  495. X/************************************************************************/
  496. XEXPORT    void    disable_logging()
  497. X
  498. X{
  499. X    if (logging) {
  500. X       fclose(logfile);
  501. X       cond_free(log_path);
  502. X       log_path = NULL;
  503. X       logging = FALSE;
  504. X       }
  505. X    xv_set(contool_base->base, FRAME_RIGHT_FOOTER, "", NULL);
  506. X}
  507. X
  508. X/************************************************************************/
  509. XEXPORT    void    enable_logging()
  510. X
  511. X{    char    buf[1024];
  512. X
  513. X    if (logging) {
  514. X       if (log_path && strcmp(log_path, defaults.log_file) == 0)
  515. X          return;
  516. X       disable_logging();
  517. X       }
  518. X    if (is_empty(defaults.log_file))
  519. X       error("You must specify a log file in the Properties dialog");
  520. X    else if ((logfile = fopen(defaults.log_file, "a")) == NULL)
  521. X       error("Cannot open log file %s : %s", defaults.log_file, sys_errlist[errno]);
  522. X    else {
  523. X       logging = TRUE;
  524. X       log_path = strsave(defaults.log_file);
  525. X       sprintf(buf, "Logging to %s...", defaults.log_file);
  526. X       xv_set(contool_base->base, FRAME_RIGHT_FOOTER, buf, NULL);
  527. X       }
  528. X}
  529. X
  530. X/************************************************************************/
  531. XEXPORT    Menu_item    start_logging(item, op)
  532. X
  533. XMenu_item    item;
  534. XMenu_generate    op;
  535. X
  536. X{    contool_base_objects    *ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  537. X
  538. X    if (op == MENU_DISPLAY)
  539. X       xv_set(item, MENU_INACTIVE, logging, NULL);
  540. X    else if (op == MENU_NOTIFY)
  541. X       enable_logging();
  542. X    return item;
  543. X}
  544. X
  545. X/************************************************************************/
  546. XEXPORT    Menu_item    stop_logging(item, op)
  547. X
  548. XMenu_item    item;
  549. XMenu_generate    op;
  550. X
  551. X{    contool_base_objects    *ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  552. X    
  553. X    if (op == MENU_DISPLAY)
  554. X       xv_set(item, MENU_INACTIVE, !logging, NULL);
  555. X    else if (op == MENU_NOTIFY)
  556. X       disable_logging();
  557. X    return item;
  558. X}
  559. X
  560. X/************************************************************************/
  561. XEXPORT    update_logging()
  562. X
  563. X{
  564. X    if (logging) {
  565. X       disable_logging();
  566. X       enable_logging();
  567. X       }
  568. X}
  569. X
  570. X/************************************************************************/
  571. XEXPORT    write_log(s)
  572. X
  573. Xchar    *s;
  574. X
  575. X{    int    t;
  576. X    static    char    hostname[100] = "";
  577. X
  578. X    if (logging) {
  579. X       if (*hostname == NULL) 
  580. X          if (gethostname(hostname, 99) != 0)
  581. X             strcpy(hostname, "(unknown)");
  582. X       t = time(0);
  583. X       fseek(logfile, 0L, 2);
  584. X       fprintf(logfile, "%s\t%.16s\t%s", hostname, ctime(&t) + 4, s);
  585. X       fflush(logfile);
  586. X       }
  587. X}
  588. END_OF_FILE
  589. if test 4036 -ne `wc -c <'logging.c'`; then
  590.     echo shar: \"'logging.c'\" unpacked with wrong size!
  591. fi
  592. # end of 'logging.c'
  593. fi
  594. if test -f 'misc.c' -a "${1}" != "-c" ; then 
  595.   echo shar: Will not clobber existing file \"'misc.c'\"
  596. else
  597. echo shar: Extracting \"'misc.c'\" \(6150 characters\)
  598. sed "s/^X//" >'misc.c' <<'END_OF_FILE'
  599. X/************************************************************************/
  600. X/*    Copyright 1988-1990 by Chuck Musciano and Harris Corporation    */
  601. X/*                                    */
  602. X/*    Permission to use, copy, modify, and distribute this software    */
  603. X/*    and its documentation for any purpose and without fee is    */
  604. X/*    hereby granted, provided that the above copyright notice    */
  605. X/*    appear in all copies and that both that copyright notice and    */
  606. X/*    this permission notice appear in supporting documentation, and    */
  607. X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  608. X/*    used in advertising or publicity pertaining to distribution    */
  609. X/*    of the software without specific, written prior permission.    */
  610. X/*    Chuck Musciano and Harris Corporation make no representations    */
  611. X/*    about the suitability of this software for any purpose.  It is    */
  612. X/*    provided "as is" without express or implied warranty.  This     */
  613. X/*    software may not be sold without the prior explicit permission    */
  614. X/*    of Harris Corporation.                        */
  615. X/************************************************************************/
  616. X
  617. X#include    <stdio.h>
  618. X#include    <ctype.h>
  619. X#include    <pwd.h>
  620. X
  621. X#include    "manifest.h"
  622. X#include    "contool.h"
  623. X
  624. X/************************************************************************/
  625. XEXPORT    int    getline(stream, string, max)
  626. X
  627. XFILE    *stream;
  628. Xchar    *string;
  629. Xint    max;
  630. X
  631. X{    register    int    i, j;
  632. X
  633. X    i = (int) fgets(string, max, stream);
  634. X    if (i == NULL)
  635. X       return(EOF);
  636. X    j = strlen(string);
  637. X    if (j > 0 && string[j - 1] == '\n')
  638. X       string[--j] = '\0';
  639. X    return(j);
  640. X}
  641. X
  642. X/************************************************************************/
  643. XPRIVATE    delarg(argc, argv)
  644. X
  645. Xint    *argc;
  646. Xchar    **argv;
  647. X
  648. X{    char    *p;
  649. X
  650. X    while (*argv = *(argv+1))
  651. X       argv++;
  652. X    (*argc)--;
  653. X}
  654. X
  655. X/************************************************************************/
  656. XEXPORT    char    getopt(argc, argv, opts, parm)
  657. X
  658. Xint    *argc;
  659. Xchar    **argv;
  660. Xchar    *opts;
  661. Xchar    **parm;
  662. X
  663. X{    char    c, *p, *strcpy(), *index();
  664. X    int    killed;
  665. X
  666. X    *parm = NULL;
  667. X    while (*argv && ((**argv != '-') || (*(*argv+1) == '\0')))
  668. X       argv++;
  669. X    if (*argv == NULL)
  670. X       return(EOF);
  671. X    c = *(*argv+1);
  672. X    *++(*argv) = '-';
  673. X    if (killed = (*(*argv+1) == '\0'))
  674. X       delarg(argc, argv);
  675. X    if ((p = index(opts, c)) == NULL)
  676. X       c = '\0';
  677. X    else if (*(p+1) == ':') {
  678. X       *parm = killed ? *argv : *argv+1;
  679. X       delarg(argc, argv);
  680. X       }
  681. X    return(c);
  682. X}
  683. X
  684. X/************************************************************************/
  685. XEXPORT    int    verify(source, valid)
  686. X
  687. Xchar    *source;
  688. Xchar    *valid;
  689. X
  690. X{    register    char    *s;
  691. X
  692. X    for ( ; *source; source++) {
  693. X       for (s = valid; *s && *s != *source; s++)
  694. X          ;
  695. X       if (*s == '\0')
  696. X          return(0);
  697. X       }
  698. X    return(1);
  699. X}
  700. X
  701. X/************************************************************************/
  702. XEXPORT    char    **saveargs(argc, argv)
  703. X
  704. Xint    argc;
  705. Xchar    **argv;
  706. X
  707. X{    int    i;
  708. X    char    **copy;
  709. X
  710. X    copy = (char **) malloc((argc + 1) * sizeof(char *));
  711. X    for (i = 0; i < argc; i++)
  712. X       strcpy(copy[i] = (char *) malloc(strlen(argv[i]) + 1), argv[i]);
  713. X    copy[i] = (char *) 0;
  714. X    return(copy);
  715. X}
  716. X
  717. X#define        SIZE_INCREMENT        8
  718. X
  719. X/************************************************************************/
  720. XEXPORT    char    **tokenize(line, argc)
  721. X
  722. Xchar    *line;
  723. Xint    *argc;
  724. X
  725. X{    char    match, **argv, *buf, *p;
  726. X    int    limit;
  727. X
  728. X    buf = (char *) malloc(strlen(line) + 1);
  729. X    *argc = 0;
  730. X    argv = (char **) malloc((limit = SIZE_INCREMENT) * sizeof(char *));
  731. X    while (*line) {
  732. X       while (isspace(*line))
  733. X          line++;
  734. X       switch (*line) {
  735. X          case '"'  :
  736. X          case '\'' : match = *line++; /* remove the quote mark */
  737. X                    for (p = buf; *line && (*line != match); ) {
  738. X                       if (*line == '\\')
  739. X                          line++;
  740. X                       if (*line)
  741. X                          *p++ = *line++;
  742. X                       }
  743. X                    if (*line)
  744. X                       line++; /* wipe out quote mark */
  745. X                    break;
  746. X          default   : for (p = buf; *line && !isspace(*line) && (*line != '"') && (*line != '\''); )
  747. X                       *p++ = *line++;
  748. X                    break;
  749. X          }
  750. X       *p = '\0';
  751. X       if (*buf) {
  752. X          argv[(*argc)++] = strsave(buf);
  753. X          if (*argc == limit)
  754. X             argv = (char **) realloc(argv, (limit += SIZE_INCREMENT) * sizeof(char *));
  755. X          }
  756. X       }
  757. X    free(buf);
  758. X    argv[*argc] = (char *) 0;
  759. X    return(argv);
  760. X}
  761. X
  762. X#define        P_POS        5
  763. X#define        L_POS        8
  764. X#define        D_POS        9
  765. X
  766. X#define        PATH        "/dev/ptyp0"
  767. X#define        LETTERS        "pqr"
  768. X#define        DIGITS        "0123456789abcdef"
  769. X
  770. XPRIVATE    char    path[12];
  771. X
  772. X/************************************************************************/
  773. XEXPORT    char    *open_psuedo_tty(master, m_mode, slave, s_mode)
  774. X
  775. XFILE    **master;
  776. Xchar    *m_mode;
  777. XFILE    **slave;
  778. Xchar    *s_mode;
  779. X
  780. X{    char    *s, *t;
  781. X
  782. X    strcpy(path, PATH);
  783. X    for (s = LETTERS; *s && *master == NULL; s++) {
  784. X       path[L_POS] = *s;
  785. X       for (t = DIGITS; *t && *master == NULL; t++) {
  786. X          path[D_POS] = *t;
  787. X          *master = fopen(path, m_mode);
  788. X          }
  789. X       }
  790. X    if (*master != NULL) {
  791. X       path[P_POS] = 't';
  792. X       *slave = fopen(path, s_mode);
  793. X       path[P_POS] = 'p';
  794. X       }
  795. X    return(path);
  796. X}
  797. X
  798. X/************************************************************************/
  799. XEXPORT    char    *expand_tilde(path)
  800. X
  801. Xchar    *path;
  802. X
  803. X{    char    s[1024], *p;
  804. X    struct    passwd    *pw;
  805. X
  806. X    if (*path == '~') {
  807. X       if (path[1] == '/' || path[1] == '\0') {
  808. X          strcpy(s, getenv("HOME"));
  809. X          strcat(s, path + 1);
  810. X          }
  811. X       else {
  812. X          if ((p = index(path, '/')) != NULL)
  813. X             *p = '\0';
  814. X          if ((pw = getpwnam(path + 1)) != NULL) {
  815. X             strcpy(s, pw->pw_dir);
  816. X             if (p != NULL) {
  817. X                strcat(s, "/");
  818. X                strcat(s, p + 1);
  819. X                }
  820. X             }
  821. X          else {
  822. X             if (p != NULL)
  823. X                *p = '/';
  824. X             strcpy(s, path);
  825. X             }
  826. X          }
  827. X       return(strsave(s));
  828. X       }
  829. X    else
  830. X       return(strsave(path));
  831. X}
  832. X
  833. X/************************************************************************/
  834. XEXPORT    int    is_empty(s)
  835. X
  836. Xchar    *s;
  837. X
  838. X{
  839. X    if (s == NULL)
  840. X       return(TRUE);
  841. X    for (; *s; s++)
  842. X       if (!isspace(*s))
  843. X          return(FALSE); 
  844. X    return(TRUE);
  845. X}
  846. X
  847. X/************************************************************************/
  848. XEXPORT    char    *check_escapes(s)
  849. X
  850. Xchar    *s;
  851. X
  852. X{    static    char    buf[1024];
  853. X    char    *p;
  854. X
  855. X    for (p = buf; *s; s++, p++)
  856. X       if (*s == '\\' || *s == '"') {
  857. X          *p++ = '\\';
  858. X          *p = *s;
  859. X          }
  860. X       else
  861. X          *p = *s;
  862. X    *p = '\0';
  863. X    return(buf);
  864. X}
  865. END_OF_FILE
  866. if test 6150 -ne `wc -c <'misc.c'`; then
  867.     echo shar: \"'misc.c'\" unpacked with wrong size!
  868. fi
  869. # end of 'misc.c'
  870. fi
  871. if test -f 'parse.y' -a "${1}" != "-c" ; then 
  872.   echo shar: Will not clobber existing file \"'parse.y'\"
  873. else
  874. echo shar: Extracting \"'parse.y'\" \(6942 characters\)
  875. sed "s/^X//" >'parse.y' <<'END_OF_FILE'
  876. X/************************************************************************/
  877. X/*    Copyright 1988-1990 by Chuck Musciano and Harris Corporation    */
  878. X/*                                    */
  879. X/*    Permission to use, copy, modify, and distribute this software    */
  880. X/*    and its documentation for any purpose and without fee is    */
  881. X/*    hereby granted, provided that the above copyright notice    */
  882. X/*    appear in all copies and that both that copyright notice and    */
  883. X/*    this permission notice appear in supporting documentation, and    */
  884. X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  885. X/*    used in advertising or publicity pertaining to distribution    */
  886. X/*    of the software without specific, written prior permission.    */
  887. X/*    Chuck Musciano and Harris Corporation make no representations    */
  888. X/*    about the suitability of this software for any purpose.  It is    */
  889. X/*    provided "as is" without express or implied warranty.  This     */
  890. X/*    software may not be sold without the prior explicit permission    */
  891. X/*    of Harris Corporation.                        */
  892. X/************************************************************************/
  893. X
  894. X%{
  895. X
  896. X#include    <stdio.h>
  897. X#include    <ctype.h>
  898. X
  899. X#include    "manifest.h"
  900. X#include    "contool.h"
  901. X
  902. XEXPORT    Props    *parsed_defaults;
  903. XEXPORT    Filter    *parsed_filters;
  904. X
  905. XEXPORT    int    parse_errors_occured;
  906. X
  907. XPRIVATE    char    *get_last_token();
  908. X
  909. XPRIVATE    Filter    *curr;
  910. XPRIVATE    char    *curr_file;
  911. XPRIVATE    int    line_count = 1;
  912. XPRIVATE    char    ungetc = -1;
  913. X
  914. X%}
  915. X
  916. X%start    configuration
  917. X
  918. X%union    {char    *cpval;
  919. X     int    ival;
  920. X     Filter    *fval;
  921. X     Props    *pval;
  922. X    }
  923. X
  924. X%token    <cpval>    STRING
  925. X%token    <ival>    INTEGER
  926. X
  927. X%token        LBRACE RBRACE
  928. X
  929. X%token        BEEP CHECK_ICON COMMAND COMMENT DEFAULTS DELETE DISPLAY FILTERS
  930. X        FLASH FLASH_ICON GOOD_ICON IGNORE LOG_BEFORE_FILTERING LOG_FILE
  931. X        MATCH NO NOFLASH NOOPEN NOSTAMP OPEN PRINT SAVE STAMP TIMESTAMP TO YES
  932. X
  933. X%type    <ival>    beep flash old_flash old_open old_stamp open stamp yes_no
  934. X%type    <cpval>    command old_end_string string
  935. X%type    <fval>    filter filter_list old_filter old_filter_list old_ignore old_save
  936. X
  937. X%%
  938. X
  939. Xconfiguration    :    empty
  940. X        |    old_style
  941. X        |    new_style
  942. X        ;
  943. X
  944. Xold_style    :    old_filter_list
  945. X                    { parsed_defaults = NULL;
  946. X                      parsed_filters = $1;
  947. X                    }
  948. X        ;
  949. X
  950. Xold_filter_list    :    old_filter
  951. X                    { $$ = $1; }
  952. X        |    old_filter_list old_filter
  953. X                    { Filter    *f;
  954. X                    
  955. X                      for (f = $1; f->next; f = f->next)
  956. X                         ;
  957. X                      f->next = $2;
  958. X                      $$ = $1;
  959. X                    }
  960. X        ;
  961. X
  962. Xold_filter    :    old_save
  963. X        |    old_ignore
  964. X        ;
  965. X
  966. Xold_save    :    SAVE beep old_flash old_open old_stamp STRING old_end_string
  967. X                    { Filter    *f;
  968. X                      char        *msg;
  969. X
  970. X                      f = (Filter *) malloc(sizeof(Filter));
  971. X                      f->save     = TRUE;
  972. X                      f->beep     = $2;
  973. X                      f->flash    = $3;
  974. X                      f->open     = $4;
  975. X                      f->stamp    = $5;
  976. X                      f->start    = $6;
  977. X                      f->stop     = $7;
  978. X                      f->start_re = NULL;
  979. X                      f->stop_re  = NULL;
  980. X                      f->command  = NULL;
  981. X                      f->comment  = NULL;
  982. X                      f->next     = NULL;
  983. X                      if (msg = compile_exp(f, f->start, f->stop))
  984. X                         yyerror(msg);
  985. X                      $$ = f;
  986. X                    }
  987. X        ;
  988. X
  989. Xold_ignore    :    IGNORE STRING old_end_string
  990. X                    { Filter    *f;
  991. X                      char        *msg;
  992. X                    
  993. X                      f = (Filter *) malloc(sizeof(Filter));
  994. X                      f->save     = FALSE;
  995. X                      f->beep     = 0;
  996. X                      f->flash    = FALSE;
  997. X                      f->open     = FALSE;
  998. X                      f->stamp    = FALSE;
  999. X                      f->start    = $2;
  1000. X                      f->stop     = $3;
  1001. X                      f->start_re = NULL;
  1002. X                      f->stop_re  = NULL;
  1003. X                      f->command  = NULL;
  1004. X                      f->comment  = NULL;
  1005. X                      f->next     = NULL;
  1006. X                      if (msg = compile_exp(f, f->start, f->stop))
  1007. X                         yyerror(msg);
  1008. X                      $$ = f;
  1009. X                    }
  1010. X        ;
  1011. X
  1012. Xold_flash    :    FLASH
  1013. X                    { $$ = TRUE; }
  1014. X        |    NOFLASH
  1015. X                    { $$ = FALSE; }
  1016. X        ;
  1017. X
  1018. Xold_open    :    OPEN
  1019. X                    { $$ = TRUE; }
  1020. X        |    NOOPEN
  1021. X                    { $$ = FALSE; }
  1022. X        ;
  1023. X
  1024. Xold_stamp    :    STAMP
  1025. X                    { $$ = TRUE; }
  1026. X        |    NOSTAMP
  1027. X                    { $$ = FALSE; }
  1028. X        ;
  1029. X
  1030. Xold_end_string    :    empty
  1031. X                    { $$ = NULL; }
  1032. X        |    TO STRING
  1033. X                    { $$ = $2; }
  1034. X        ;
  1035. X
  1036. Xnew_style    :    defaults
  1037. X        |    filters
  1038. X        |    defaults filters
  1039. X        ;
  1040. X
  1041. Xdefaults    :    DEFAULTS
  1042. X                    { parsed_defaults = (Props *) malloc(sizeof(Props));
  1043. X                      *parsed_defaults = defaults;
  1044. X                    }
  1045. X            LBRACE default_list RBRACE
  1046. X        ;
  1047. X
  1048. Xfilters        :    FILTERS LBRACE filter_list RBRACE
  1049. X                    { parsed_filters = $3; }
  1050. X        ;
  1051. X
  1052. Xdefault_list    :    empty
  1053. X        |    default_list default
  1054. X        ;
  1055. X
  1056. Xdefault        :    beep
  1057. X                    { parsed_defaults->beep = $1; }
  1058. X        |    command
  1059. X                    { parsed_defaults->command = $1; }
  1060. X        |    flash
  1061. X                    { parsed_defaults->flash = $1; }
  1062. X        |    open
  1063. X                    { parsed_defaults->open = $1; }
  1064. X        |    stamp
  1065. X                    { parsed_defaults->stamp = $1; }
  1066. X        |    CHECK_ICON string
  1067. X                    { parsed_defaults->bad_icon = $2; }
  1068. X        |    DELETE INTEGER
  1069. X                    { parsed_defaults->delete_amount = $2; }
  1070. X        |    DISPLAY INTEGER
  1071. X                    { parsed_defaults->max_size = $2; }
  1072. X        |    FLASH_ICON string
  1073. X                    { parsed_defaults->flash_icon = $2; }
  1074. X        |    GOOD_ICON string
  1075. X                    { parsed_defaults->good_icon = $2; }
  1076. X        |    LOG_BEFORE_FILTERING yes_no
  1077. X                    { parsed_defaults->log_after = !$2; }
  1078. X        |    LOG_FILE string
  1079. X                    { parsed_defaults->log_file = $2; }
  1080. X        |    PRINT STRING
  1081. X                    { parsed_defaults->print_filter = $2; }
  1082. X        |    TIMESTAMP INTEGER
  1083. X                    { parsed_defaults->stamp_resolution = $2; }
  1084. X        ;
  1085. X
  1086. Xfilter_list    :    empty
  1087. X                    { $$ = NULL; }
  1088. X        |    filter_list filter
  1089. X                    { Filter    *f;
  1090. X                    
  1091. X                      if ($1 == NULL)
  1092. X                         $$ = $2;
  1093. X                      else {
  1094. X                         for (f = $1; f->next; f = f->next)
  1095. X                            ;
  1096. X                         f->next = $2;
  1097. X                         $$ = $1;
  1098. X                         }
  1099. X                    }
  1100. X        ;
  1101. X
  1102. Xfilter        :    LBRACE
  1103. X                    { curr = (Filter *) malloc(sizeof(Filter));
  1104. X                      bzero(curr, sizeof(Filter));
  1105. X                    }
  1106. X            filter_attr_list RBRACE
  1107. X                    { char    *msg;
  1108. X                    
  1109. X                      if (curr->start == NULL)
  1110. X                         yyerror("no filter pattern specified");
  1111. X                      if (msg = compile_exp(curr, curr->start, curr->stop))
  1112. X                         yyerror(msg);
  1113. X                      $$ = curr;
  1114. X                    }
  1115. X        ;
  1116. X
  1117. Xfilter_attr_list:    empty
  1118. X        |    filter_attr_list filter_attr
  1119. X        ;
  1120. X
  1121. Xfilter_attr    :    beep
  1122. X                    { curr->beep = $1; }
  1123. X        |    command
  1124. X                    { curr->command = $1; }
  1125. X        |    flash
  1126. X                    { curr->flash = $1; }
  1127. X        |    open
  1128. X                    { curr->open = $1; }
  1129. X        |    stamp
  1130. X                    { curr->stamp = $1; }
  1131. X        |    COMMENT string
  1132. X                    { curr->comment = $2; }
  1133. X        |    IGNORE yes_no
  1134. X                    { curr->save = !$2; }
  1135. X        |    MATCH string
  1136. X                    { curr->start = $2; }
  1137. X        |    TO string
  1138. X                    { curr->stop = $2; }
  1139. X        ;
  1140. X
  1141. Xbeep        :    BEEP INTEGER
  1142. X                    { $$ = $2; }
  1143. X        ;
  1144. X
  1145. Xcommand        :    COMMAND string
  1146. X                    { $$ = $2; }
  1147. X        ;
  1148. Xflash        :    FLASH yes_no
  1149. X                    { $$ = $2; }
  1150. X        ;
  1151. X
  1152. Xopen        :    OPEN yes_no
  1153. X                    { $$ = $2; }
  1154. X        ;
  1155. X
  1156. Xstamp        :    STAMP yes_no
  1157. X                    { $$ = $2; }
  1158. X        ;
  1159. X
  1160. Xyes_no        :    YES
  1161. X                    { $$ = TRUE; }
  1162. X        |    NO
  1163. X                    { $$ = FALSE; }
  1164. X        ;
  1165. X
  1166. Xstring        :    STRING
  1167. X                    { $$ = (*$1 == '\0')? NULL : $1; }
  1168. X        ;
  1169. X
  1170. Xempty        : ;
  1171. X
  1172. X%%
  1173. X
  1174. X/************************************************************************/
  1175. XPRIVATE    yyerror(s1, s2, s3, s4, s5, s6, s7)
  1176. X
  1177. Xchar    *s1, *s2, *s3, *s4, *s5, *s6, *s7;
  1178. X
  1179. X{    char    buf1[1024], buf2[1024];
  1180. X
  1181. X    sprintf(buf1, "%s: line %d: ", curr_file, line_count - ((ungetc == '\n')? 1 : 0));
  1182. X    sprintf(buf2, s1, s2, s3, s4, s5, s6, s7);
  1183. X    strcat(buf1, buf2);
  1184. X    if (strcmp(s1, "syntax error") == 0) {
  1185. X       strcat(buf1, " at or near ");
  1186. X       strcat(buf1, get_last_token());
  1187. X       }
  1188. X    error(buf1);
  1189. X    yyclearin;
  1190. X    parse_errors_occured++;
  1191. X}
  1192. X
  1193. X#include "lex.c"
  1194. END_OF_FILE
  1195. if test 6942 -ne `wc -c <'parse.y'`; then
  1196.     echo shar: \"'parse.y'\" unpacked with wrong size!
  1197. fi
  1198. # end of 'parse.y'
  1199. fi
  1200. if test -f 'regexp.c' -a "${1}" != "-c" ; then 
  1201.   echo shar: Will not clobber existing file \"'regexp.c'\"
  1202. else
  1203. echo shar: Extracting \"'regexp.c'\" \(3483 characters\)
  1204. sed "s/^X//" >'regexp.c' <<'END_OF_FILE'
  1205. X/************************************************************************/
  1206. X/*    Copyright 1988-1990 by Chuck Musciano and Harris Corporation    */
  1207. X/*                                    */
  1208. X/*    Permission to use, copy, modify, and distribute this software    */
  1209. X/*    and its documentation for any purpose and without fee is    */
  1210. X/*    hereby granted, provided that the above copyright notice    */
  1211. X/*    appear in all copies and that both that copyright notice and    */
  1212. X/*    this permission notice appear in supporting documentation, and    */
  1213. X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  1214. X/*    used in advertising or publicity pertaining to distribution    */
  1215. X/*    of the software without specific, written prior permission.    */
  1216. X/*    Chuck Musciano and Harris Corporation make no representations    */
  1217. X/*    about the suitability of this software for any purpose.  It is    */
  1218. X/*    provided "as is" without express or implied warranty.  This     */
  1219. X/*    software may not be sold without the prior explicit permission    */
  1220. X/*    of Harris Corporation.                        */
  1221. X/************************************************************************/
  1222. X
  1223. X#include    <stdio.h>
  1224. X
  1225. X#include    "manifest.h"
  1226. X#include    "contool.h"
  1227. X
  1228. XPRIVATE    regexp_error();
  1229. X
  1230. X#define        INIT            register char *expbuf = ep, *sp = instring;
  1231. X#define        GETC()            (*sp++)
  1232. X#define        PEEKC()            (*sp)
  1233. X#define        UNGETC(c)        (--sp)
  1234. X#define        RETURN(p)        {bcopy(expbuf, sp = (char *) malloc(p - expbuf), p - expbuf); return(sp);}
  1235. X#define        ERROR(val)        {regexp_error(val, instring); return(NULL);}
  1236. X
  1237. X#include    <regexp.h>
  1238. X
  1239. XPRIVATE    char    error_message[512];
  1240. X
  1241. X/************************************************************************/
  1242. XEXPORT    int    match_exp(exp, circ, str)
  1243. X
  1244. Xchar    *exp;
  1245. Xint    circ;
  1246. Xchar    *str;
  1247. X
  1248. X{    char    *p;
  1249. X    int    result;
  1250. X
  1251. X    p = str + strlen(str) - 1;
  1252. X    if (p >= str && *p == '\n')
  1253. X       *p = '\0';
  1254. X    circf = circ;
  1255. X    result = step(str, exp);
  1256. X    if (p >= str && *p == '\0')
  1257. X       *p = '\n';
  1258. X    return(result);
  1259. X}
  1260. X
  1261. X/************************************************************************/
  1262. XPRIVATE    regexp_error(val, string)
  1263. X
  1264. Xint    val;
  1265. Xchar    *string;
  1266. X
  1267. X{    char    *msg;
  1268. X
  1269. X    switch (val) {
  1270. X       case 11 : msg = "range endpoint too large";
  1271. X       case 16 : msg = "bad number";
  1272. X       case 25 : msg = "\"\\digit\" out of range";
  1273. X       case 36 : msg = "illegal or missing delimiter";
  1274. X       case 41 : msg = "no remembered search string";
  1275. X       case 42 : msg = "\\(\\) imbalance";
  1276. X       case 43 : msg = "too many \\(";
  1277. X       case 44 : msg = "more than 2 numbers given in \\{\\}";
  1278. X       case 45 : msg = "} expected after \\";
  1279. X       case 46 : msg = "first number exceeds second in \\{\\}";
  1280. X       case 49 : msg = "[] imbalance";
  1281. X       case 50 : msg = "regular expression overflow";
  1282. X       default : msg = "regular expression error";
  1283. X       }
  1284. X    sprintf(error_message, "%s in %s", msg, string);
  1285. X}
  1286. X
  1287. X/************************************************************************/
  1288. XEXPORT    char    *compile_exp(filter, start, stop)
  1289. X
  1290. XFilter    *filter;
  1291. Xchar    *start;
  1292. Xchar    *stop;
  1293. X
  1294. X{    char    rbuf[1024], *sre, *ere;
  1295. X    int    sc, ec;
  1296. X
  1297. X    sre = ere = NULL;
  1298. X    if (start) {
  1299. X       if ((sre = compile(start, rbuf, rbuf+1024, '\0')) == NULL)
  1300. X          return(error_message);
  1301. X       sc = circf;
  1302. X       }
  1303. X    if (stop) {
  1304. X       if ((ere = compile(stop, rbuf, rbuf+1024, '\0')) == NULL) {
  1305. X          cond_free(sre);
  1306. X          return(error_message);
  1307. X          }
  1308. X       ec = circf;
  1309. X       }
  1310. X    if (filter) {
  1311. X       filter->start = start;
  1312. X       filter->stop = stop;
  1313. X       filter->start_re = sre;
  1314. X       filter->stop_re = ere;
  1315. X       filter->start_circf = sc;
  1316. X       filter->stop_circf = ec;
  1317. X       }
  1318. X    else {
  1319. X       cond_free(sre);
  1320. X       if (ere)
  1321. X          cond_free(ere);
  1322. X       }
  1323. X    return(NULL);
  1324. X}
  1325. END_OF_FILE
  1326. if test 3483 -ne `wc -c <'regexp.c'`; then
  1327.     echo shar: \"'regexp.c'\" unpacked with wrong size!
  1328. fi
  1329. # end of 'regexp.c'
  1330. fi
  1331. if test -f 'store.c' -a "${1}" != "-c" ; then 
  1332.   echo shar: Will not clobber existing file \"'store.c'\"
  1333. else
  1334. echo shar: Extracting \"'store.c'\" \(5792 characters\)
  1335. sed "s/^X//" >'store.c' <<'END_OF_FILE'
  1336. X/************************************************************************/
  1337. X/*    Copyright 1988-1990 by Chuck Musciano and Harris Corporation    */
  1338. X/*                                    */
  1339. X/*    Permission to use, copy, modify, and distribute this software    */
  1340. X/*    and its documentation for any purpose and without fee is    */
  1341. X/*    hereby granted, provided that the above copyright notice    */
  1342. X/*    appear in all copies and that both that copyright notice and    */
  1343. X/*    this permission notice appear in supporting documentation, and    */
  1344. X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  1345. X/*    used in advertising or publicity pertaining to distribution    */
  1346. X/*    of the software without specific, written prior permission.    */
  1347. X/*    Chuck Musciano and Harris Corporation make no representations    */
  1348. X/*    about the suitability of this software for any purpose.  It is    */
  1349. X/*    provided "as is" without express or implied warranty.  This     */
  1350. X/*    software may not be sold without the prior explicit permission    */
  1351. X/*    of Harris Corporation.                        */
  1352. X/************************************************************************/
  1353. X
  1354. X/************************************************************************/
  1355. X/*                                    */
  1356. X/*    store.c        contool store dialog manager            */
  1357. X/*                                    */
  1358. X/************************************************************************/
  1359. X
  1360. X#include    <stdio.h>
  1361. X#include    <ctype.h>
  1362. X#include    <sys/param.h>
  1363. X#include    <sys/types.h>
  1364. X#include    <sys/file.h>
  1365. X#include    <xview/xview.h>
  1366. X#include    <xview/panel.h>
  1367. X#include    <xview/notice.h>
  1368. X#include    <xview/xv_xrect.h>
  1369. X
  1370. X#include    "manifest.h"
  1371. X#include    "contool.h"
  1372. X#include    "contool_ui.h"
  1373. X
  1374. X#define        yes_no(x)        ((x)? "yes" : "no")
  1375. X
  1376. XPUBLIC    contool_base_objects    *contool_base;
  1377. X
  1378. XPRIVATE    contool_store_objects    *contool_store = NULL;
  1379. X
  1380. X/************************************************************************/
  1381. XEXPORT    Menu_item    popup_save_config(item, op)
  1382. X
  1383. XMenu_item    item;
  1384. XMenu_generate    op;
  1385. X
  1386. X{    contool_base_objects * ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1387. X
  1388. X    if (op == MENU_NOTIFY) {
  1389. X       if (contool_store == NULL) {
  1390. X          contool_store = contool_store_objects_initialize(NULL, ip->base);
  1391. X          xv_set(contool_store->store_file,
  1392. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  1393. X                      PANEL_NOTIFY_STRING, "\n\r ",
  1394. X                   NULL);
  1395. X          xv_set(contool_store->store_type, PANEL_VALUE, 3, NULL);
  1396. X          place_dialog(ip->base, contool_store->store);
  1397. X          }
  1398. X       xv_set(contool_store->store_file, PANEL_VALUE, filter_file, NULL);
  1399. X       xv_set(contool_store->store, XV_SHOW, TRUE, NULL);
  1400. X       }
  1401. X    return item;
  1402. X}
  1403. X
  1404. X/************************************************************************/
  1405. XEXPORT    void    store_filters(item, event)
  1406. X
  1407. XPanel_item    item;
  1408. XEvent        *event;
  1409. X
  1410. X{    contool_store_objects    *ip = (contool_store_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1411. X    char    *path, buf[1024];
  1412. X    FILE    *f;
  1413. X    int    kind;
  1414. X    Filter    *filt;
  1415. X
  1416. X    path = expand_tilde(xv_get(ip->store_file, PANEL_VALUE));
  1417. X    if (access(path, W_OK) == 0) {
  1418. X       sprintf(buf, "File \"%s\" exists.  You can:", path);
  1419. X       kind = notice_prompt(contool_base->base, NULL,
  1420. X                      NOTICE_MESSAGE_STRINGS, buf, NULL,
  1421. X                      NOTICE_BUTTON_YES, "Overwrite",
  1422. X                      NOTICE_BUTTON_NO, "Cancel",
  1423. X                   NULL);
  1424. X       if (kind == 0) {
  1425. X          xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1426. X          free(path);
  1427. X          return;
  1428. X          }
  1429. X       }
  1430. X    if ((f = fopen(path, "w")) == NULL) {
  1431. X       error("Cannot write to %s: %s", path, sys_errlist[errno]);
  1432. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1433. X       free(path);
  1434. X       }
  1435. X    else {
  1436. X       kind = (int) xv_get(ip->store_type, PANEL_VALUE);
  1437. X       if (kind & 1) {
  1438. X          fprintf(f, "defaults {\n");
  1439. X          fprintf(f, "   beep                 %d\n", defaults.beep);
  1440. X          fprintf(f, "   command              \"%s\"\n", check_escapes(is_null(defaults.command)));
  1441. X          fprintf(f, "   flash                %s\n", yes_no(defaults.flash));
  1442. X          fprintf(f, "   open                 %s\n", yes_no(defaults.open));
  1443. X          fprintf(f, "   stamp                %s\n", yes_no(defaults.stamp));
  1444. X          fprintf(f, "   good_icon            \"%s\"\n", is_null(defaults.good_icon));
  1445. X          fprintf(f, "   check_icon           \"%s\"\n", is_null(defaults.bad_icon));
  1446. X          fprintf(f, "   flash_icon           \"%s\"\n", is_null(defaults.flash_icon));
  1447. X          fprintf(f, "   print                \"%s\"\n", defaults.print_filter);
  1448. X          fprintf(f, "   log_file             \"%s\"\n", is_null(defaults.log_file));
  1449. X          fprintf(f, "   log_before_filtering %s\n", yes_no(!defaults.log_after));
  1450. X          fprintf(f, "   timestamp            %d\n", defaults.stamp_resolution);
  1451. X          fprintf(f, "   display              %d\n", defaults.max_size);
  1452. X          fprintf(f, "   delete               %d\n", defaults.delete_amount);
  1453. X          fprintf(f, "}\n");
  1454. X          }
  1455. X       if (kind & 2) {
  1456. X          fprintf(f, "filters {\n");
  1457. X          for (filt = filters; filt; filt = filt->next) {
  1458. X             fprintf(f, "   {\n");
  1459. X             fprintf(f, "      match   \"%s\"\n", check_escapes(filt->start));
  1460. X             if (filt->stop)
  1461. X                fprintf(f, "      to      \"%s\"\n", check_escapes(filt->stop));
  1462. X             if (filt->comment)
  1463. X                fprintf(f, "      comment \"%s\"\n", check_escapes(filt->comment));
  1464. X             if (filt->save) {
  1465. X                fprintf(f, "      ignore  no\n");
  1466. X                fprintf(f, "      beep    %d\n", filt->beep);
  1467. X                fprintf(f, "      command \"%s\"\n", check_escapes(is_null(filt->command)));
  1468. X                fprintf(f, "      flash   %s\n", yes_no(filt->flash));
  1469. X                fprintf(f, "      open    %s\n", yes_no(filt->open));
  1470. X                fprintf(f, "      stamp   %s\n", yes_no(filt->stamp));
  1471. X                }
  1472. X             else
  1473. X                fprintf(f, "      ignore  yes\n");
  1474. X             fprintf(f, "   }\n");
  1475. X             }
  1476. X          fprintf(f, "}\n");
  1477. X          }
  1478. X       fclose(f);
  1479. X       filter_file = path;
  1480. X       }
  1481. X}
  1482. END_OF_FILE
  1483. if test 5792 -ne `wc -c <'store.c'`; then
  1484.     echo shar: \"'store.c'\" unpacked with wrong size!
  1485. fi
  1486. # end of 'store.c'
  1487. fi
  1488. echo shar: End of archive 2 \(of 6\).
  1489. cp /dev/null ark2isdone
  1490. MISSING=""
  1491. for I in 1 2 3 4 5 6 ; do
  1492.     if test ! -f ark${I}isdone ; then
  1493.     MISSING="${MISSING} ${I}"
  1494.     fi
  1495. done
  1496. if test "${MISSING}" = "" ; then
  1497.     echo You have unpacked all 6 archives.
  1498.     rm -f ark[1-9]isdone
  1499. else
  1500.     echo You still need to unpack the following archives:
  1501.     echo "        " ${MISSING}
  1502. fi
  1503. ##  End of shell archive.
  1504. exit 0
  1505.  
  1506. Chuck Musciano                ARPA  : chuck@trantor.harris-atd.com
  1507. Harris Corporation             Usenet: ...!uunet!x102a!trantor!chuck
  1508. PO Box 37, MS 3A/1912            AT&T  : (407) 727-6131
  1509. Melbourne, FL 32902            FAX   : (407) 727-{5118,5227,4004}
  1510.  
  1511. I'm glad you asked, son.  Being popular
  1512.     is the most important thing in the world.    -- Homer Simpson
  1513.